import Vue from 'vue'
import Router from 'vue-router'

// 导入登录组件
// import Login from '@/components/Login'
const Login = () => import(/* webpackChunkName: "group-home" */ '@/components/Login')
// 导入 后台首页组件
// import Home from '@/components/Home'
const Home = () => import(/* webpackChunkName: "group-home" */ '@/components/Home')
// 导入 欢迎组件
// import Welcome from '@/components/Welcome'
const Welcome = () => import(/* webpackChunkName: "group-home" */ '@/components/Welcome')

// 导入 用户管理组件
// import Users from '@/components/user/Users'
const Users = () => import(/* webpackChunkName: "group-user" */ '@/components/user/Users')
// 导入 权限列表组件
// import Rights from '@/components/power/Rights'
const Rights = () => import(/* webpackChunkName: "group-user" */ '@/components/power/Rights')
// / 导入 权限列表组件
// import Rights from '@/components/power/Rights'
const Permission = () => import(/* webpackChunkName: "group-user" */ '@/components/power/Permission')
// 导入 角色列表组件
// import Roles from '@/components/power/Roles'
const Roles = () => import(/* webpackChunkName: "group-user" */ '@/components/power/Roles')

// 导入 商品分类组件
// import Category from '@/components/goods/Category'
const Category = () => import(/* webpackChunkName: "group-cate_params" */ '@/components/goods/Category')
// 导入 商品参数组件
// import Params from '@/components/goods/Params'
const Params = () => import(/* webpackChunkName: "group-cate_params" */ '@/components/goods/Params')

// 导入 商品容器组件
// import GoodsContainer from '@/components/goods/GoodsContainer'
const GoodsContainer = () => import(/* webpackChunkName: "group-goods" */ '@/components/goods/GoodsContainer')
// 导入 商品列表组件
// import GoodsList from '@/components/goods/List'
const GoodsList = () => import(/* webpackChunkName: "group-goods" */ '@/components/goods/List')

// import GoodsList from '@/components/goods/List'
const GoodsListNew = () => import(/* webpackChunkName: "group-goods" */ '@/components/goods/ListNew')

// 导入 商品添加组件
// import GoodsAdd from '@/components/goods/Add'
const GoodsAdd = () => import(/* webpackChunkName: "group-goods" */ '@/components/goods/Add')

const GoodsEdit = () => import(/* webpackChunkName: "group-goods" */ '@/components/goods/edit')
const goodSpecType = () => import(/* webpackChunkName: "group-goods" */ '@/components/goods/goodSpecType')

// 导入 订单组件
// import Order from '@/components/order/Order'
const Order = () => import(/* webpackChunkName: "group-order_report" */ '@/components/order/Order')
// 导入 报表组件
// import Report from '@/components/report/Report'
const Report = () => import(/* webpackChunkName: "group-order_report" */ '@/components/report/Report')

// 导入 报表组件
// import Report from '@/components/report/Report'
const abnormalData = () => import(/* webpackChunkName: "group-order_report" */ '@/components/report/abnormalData')

// 导入 申购组件
// import Report from '@/components/report/Report'
const shengou = () => import(/* webpackChunkName: "group-order_report" */ '@/components/shengou/shengou')

// 导入 申购组件
// import Report from '@/components/report/Report'
const kefu = () => import(/* webpackChunkName: "group-order_report" */ '@/components/kefu/kefu')
// 导入 汇率
// import Report from '@/components/report/Report'
const exchange = () => import(/* webpackChunkName: "group-order_report" */ '@/components/configurtion/exchange')
// 版本管理
// import Report from '@/components/report/Report'
const versions = () => import(/* webpackChunkName: "group-order_report" */ '@/components/configurtion/versions')

const annconment = () => import(/* webpackChunkName: "group-order_report" */ '@/components/configurtion/annconment')
// 用户管理
// import Report from '@/components/report/Report'
const userList = () => import(/* webpackChunkName: "group-order_report" */ '@/components/user/userList')

// 申诉详情
// import Report from '@/components/report/Report'
const applyDetlie = () => import(/* webpackChunkName: "group-order_report" */ '@/components/order/applyDetlie')
// 用户反馈列表
// import Report from '@/components/report/Report'
const userfeedback = () => import(/* webpackChunkName: "group-order_report" */ '@/components/user/userfeedback')
// import Report from '@/components/report/Report'
const userRealname = () => import(/* webpackChunkName: "group-order_report" */ '@/components/user/userRealname')

//定时器列表
// import Report from '@/components/report/Report'
const timer = () => import(/* webpackChunkName: "group-order_report" */ '@/components/system/timer')
//

//chengjiao列表
// import Report from '@/components/report/Report'
const orderlist = () => import(/* webpackChunkName: "group-order_report" */ '@/components/order/orderlist')
//

// import Report from '@/components/report/Report'
const activitylist = () => import(/* webpackChunkName: "group-order_report" */ '@/components/configurtion/activitylist')
//
//系统用户
// import Report from '@/components/report/Report'
const systemUser = () => import(/* webpackChunkName: "group-order_report" */ '@/components/power/systemUser')
//系统用户
// import Report from '@/components/report/Report'
const cateList = () => import(/* webpackChunkName: "group-order_report" */ '@/components/goods/cateList')


//系统用户
// import Report from '@/components/report/Report'
const mention = () => import(/* webpackChunkName: "group-order_report" */ '@/components/order/mention')

//商家中心
// import Report from '@/components/report/Report'
const merchantCenter = () => import(/* webpackChunkName: "group-order_report" */ '@/components/merchantCenter/merchantCenter')

//商家中心 商家上传商品审核List
// import Report from '@/components/report/Report'
const productAudit = () => import(/* webpackChunkName: "group-order_report" */ '@/components/merchantCenter/productAuditList')

//7益订单列表
const qiyiOrderList=()=>import('@/components/configurtion/qiyiOrderList')

//CY活币列表
const cyNumRank=()=>import('@/components/report/cyNumRank')

//茶益堂列表
const chayitangManage=()=>import('@/components/configurtion/chayitangManage')

//法币商家申请列表
const fabiMerchant=()=>import('@/components/merchantCenter/usdtMerchant')

//新加 实名认证列表
const realList=()=>import('@/components/user/realList')
const sellerList=()=>import('@/components/user/sellerList')

//新加 配置列表
const configList=()=>import('@/components/configurtion/configList')

//新加 轮播图配置
const loopImage=()=>import('@/components/configurtion/loopImage')
const carList=()=>import('@/components/configurtion/carList')
const videoList=()=>import('@/components/configurtion/videoList')
const tuijianList=()=>import('@/components/configurtion/tuijianList')
//新加 素材类型配置
const materialType=()=>import('@/components/configurtion/materialType')
const material=()=>import('@/components/configurtion/material')


//新加 快报列表
const expressList=()=>import('@/components/configurtion/expressList')

//币种列表
const coinList=()=>import('@/components/power/coinList')

//头条配置
const newsConfig=()=>import('@/components/configurtion/newsConfig')

Vue.use(Router)

const router = new Router({
  routes: [
    {
      path: '/',
      redirect: '/login' // 如果用户访问的 / 根路径，则 重定向到 /login 页面
    },
    {
      path: '/login',
      component: Login
    }, // 登录页面的路由规则
    {
      path: '/home',
      component: Home,

      redirect: '/welcome', // 只要进入了 home 页面，就立即重定向到 welcome 欢迎页
      name:'home',
      children: [
        { path: '/welcome', component: Welcome,name:'welcome' },
        { path: '/roles', component: Roles,name:'roles'},
        {
          path: '/goods',
          component: GoodsContainer,
          redirect: '/goods/list',
          name:'goods',
          children: [
            { path: '/goods/list', component: GoodsList,name:'goods/list' },
            { path: '/goods/add', component: GoodsAdd,name:'goods/add' },
            { path: '/goods/edit', component: GoodsEdit,name:'goods/list'},
            { path: '/goods/listNew', component: GoodsListNew,name:'goods/listNew'},
          ],
        },
        { path: '/tuijianList', component: tuijianList,name:'tuijianList' },
        { path: '/videoList', component: videoList,name:'videoList' },
        { path: '/orders', component: Order,name:'orders' },
        { path: '/reports', component: Report ,name:'reports'},
        { path: '/abnormalData', component: abnormalData ,name:'abnormalData'},
        { path: '/shengou', component: shengou ,name:'shengou'},
        { path: '/kefu', component: kefu ,name:'kefu'},
        { path: '/exchange', component: exchange ,name:'exchange'},
        { path: '/versions', component: versions ,name:'versions'},
        { path: '/userList', component: userList ,name:'userList'},
        { path: '/applyDetlie', component: applyDetlie ,name:'applyDetlie'},
        { path: '/userfeedback', component: userfeedback ,name:'userfeedback'},
        { path: '/userRealname', component: userRealname ,name:'userRealname'},
        { path: '/goodSpecType', component: goodSpecType,name:'goodSpecType'},
        { path: '/Permission', component: Permission ,name:'Permission'},
        { path: '/timer', component: timer ,name:'timer'},
        { path: '/systemUser', component: systemUser,name:'systemUser' },
        { path: '/orderlist', component: orderlist ,name:'orderlist'},
        { path: '/annconment', component: annconment,name:'annconment' },
        { path: '/activitylist', component: activitylist ,name:'activitylist'},
        { path: '/cateList', component: cateList ,name:'cateList'},
        { path: '/mention', component: mention ,name:'mention'},
        { path: '/merchantCenter', component: merchantCenter,name:'merchantCenter'},//商家中心
        { path: '/productAuditList', component: productAudit,name:'productAuditList' },//商家商品审核列表
        { path: '/qiyiOrderList', component: qiyiOrderList ,name:'qiyiOrderList'},//七益订单列表
        { path: '/cyNumRank', component: cyNumRank ,name:'cyNumRank'},//CY活币列表
        { path: '/chayitangManage', component: chayitangManage,name:'chayitangManage'},//七益订单列表
        { path: '/fabiMerchant', component: fabiMerchant,name:'fabiMerchant'},//法币商家列表
        { path: '/sellerList', component: sellerList,name:'sellerList'},
        { path: '/realList', component: realList,name:'realList'},//新加 实名认证列表
        { path: '/configList', component: configList,name:'configList'},//新加 配置列表
        { path: '/loopImage', component: loopImage,name:'loopImage'},//新加 配置列表
        { path: '/carList', component: carList,name:'carList'},
        { path: '/materialType', component: materialType,name:'materialType'},//新加 配置列表
        { path: '/material', component: material,name:'material'},//新加 配置列表
        { path: '/expressList', component: expressList,name:'expressList'},//新加 快报列表
        { path: '/categories', component: Category,name:'categories'},//新加 商品分类
        { path: '/coinList', component: coinList,name:'coinList'},//币种列表
        { path: '/newsConfig', component: newsConfig,name:'newsConfig'},//头条配置

      ]
    } // 后台主页的路由规则
  ]
})

// 路由导航守卫的语法   router对象.beforeEach((to, from, next) => {})
router.beforeEach((to, from, next) => {
  // 如果用户访问的是 登录页面，则直接放行
  if (to.path === '/login') return next()
  // 获取 token
  const tokenStr = sessionStorage.getItem('token')
  // 如果 token 存在， 直接放行
  if (tokenStr) return next()
  // 否则，强制跳转到登录页
  next('/login')
})

export default router
